/**
 * 
 */
package org.vidyakiran.app.server.domain.entity;

import java.io.Serializable;

import javax.persistence.Basic;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.ManyToOne;
import javax.persistence.MappedSuperclass;

import org.vidyakiran.app.server.domain.reference.City;

/**
 * @author Harpreet
 *
 */
@MappedSuperclass
@Entity
public abstract class Address implements Serializable {

	private static final long serialVersionUID = 8136142500922124015L;

	@Id
	@GeneratedValue(strategy = GenerationType.IDENTITY)
	private Long id;

	@Basic
	protected String firstLine;
	
	@Basic
	protected String secondLine;
	
	@Basic
	protected String thirdLine;
	
	@ManyToOne(fetch =FetchType.LAZY)
	protected City city;
	
	//TODO Will need this in future build
	//@ManyToOne(fetch = FetchType.LAZY)
	//protected State state;
	
	@Basic
	protected Long pincode;
	
	//TODO Will need this in future build
	//protected Country country;

	/**
	 * @return the id
	 */
	public Long getId() {
		return id;
	}

	/**
	 * @param id the id to set
	 */
	public void setId(Long id) {
		this.id = id;
	}

	/**
	 * @return the firstLine
	 */
	public String getFirstLine() {
		return firstLine;
	}

	/**
	 * @param firstLine the firstLine to set
	 */
	public void setFirstLine(String firstLine) {
		this.firstLine = firstLine;
	}

	/**
	 * @return the secondLine
	 */
	public String getSecondLine() {
		return secondLine;
	}

	/**
	 * @param secondLine the secondLine to set
	 */
	public void setSecondLine(String secondLine) {
		this.secondLine = secondLine;
	}

	/**
	 * @return the thirdLine
	 */
	public String getThirdLine() {
		return thirdLine;
	}

	/**
	 * @param thirdLine the thirdLine to set
	 */
	public void setThirdLine(String thirdLine) {
		this.thirdLine = thirdLine;
	}

	/**
	 * @return the city
	 */
	public City getCity() {
		return city;
	}

	/**
	 * @param city the city to set
	 */
	public void setCity(City city) {
		this.city = city;
	}

//	/**
//	 * @return the state
//	 */
//	public State getState() {
//		return state;
//	}
//
//	/**
//	 * @param state the state to set
//	 */
//	public void setState(State state) {
//		this.state = state;
//	}

	/**
	 * @return the pincode
	 */
	public Long getPincode() {
		return pincode;
	}

	/**
	 * @param pincode the pincode to set
	 */
	public void setPincode(Long pincode) {
		this.pincode = pincode;
	}

//	/**
//	 * @return the country
//	 */
//	public Country getCountry() {
//		return country;
//	}
//
//	/**
//	 * @param country the country to set
//	 */
//	public void setCountry(Country country) {
//		this.country = country;
//	}

	/* (non-Javadoc)
	 * @see java.lang.Object#hashCode()
	 */
	@Override
	public int hashCode() {
		final int prime = 31;
		int result = 1;
		result = prime * result
				+ ((firstLine == null) ? 0 : firstLine.hashCode());
		result = prime * result + ((pincode == null) ? 0 : pincode.hashCode());
		result = prime * result
				+ ((secondLine == null) ? 0 : secondLine.hashCode());
		result = prime * result
				+ ((thirdLine == null) ? 0 : thirdLine.hashCode());
		return result;
	}

	/* (non-Javadoc)
	 * @see java.lang.Object#equals(java.lang.Object)
	 */
	@Override
	public boolean equals(Object obj) {
		if (this == obj)
			return true;
		if (obj == null)
			return false;
		if (getClass() != obj.getClass())
			return false;
		Address other = (Address) obj;
		if (firstLine == null) {
			if (other.firstLine != null)
				return false;
		} else if (!firstLine.equals(other.firstLine))
			return false;
		if (pincode == null) {
			if (other.pincode != null)
				return false;
		} else if (!pincode.equals(other.pincode))
			return false;
		if (secondLine == null) {
			if (other.secondLine != null)
				return false;
		} else if (!secondLine.equals(other.secondLine))
			return false;
		if (thirdLine == null) {
			if (other.thirdLine != null)
				return false;
		} else if (!thirdLine.equals(other.thirdLine))
			return false;
		return true;
	}

	/* (non-Javadoc)
	 * @see java.lang.Object#toString()
	 */
	@Override
	public String toString() {
		return "Address ["
				+ (firstLine != null ? "firstLine=" + firstLine + ", " : "")
				+ (id != null ? "id=" + id + ", " : "")
				+ (pincode != null ? "pincode=" + pincode + ", " : "")
				+ (secondLine != null ? "secondLine=" + secondLine + ", " : "")
				+ (thirdLine != null ? "thirdLine=" + thirdLine : "") + "]";
	}

}
